import { createStore, combineReducers, applyMiddleware } from "redux";
import { persistStore, persistReducer } from "redux-persist";
import storage from "redux-persist/lib/storage";
import { userReducer } from './reducers/user'
import { tabReducer } from './reducers/tab'
import { addressReducer } from "./reducers/address";
import {orderReducer } from "./reducers/order"

import thunk from 'redux-thunk'

const persistConfig = {
  key: "root",
  storage,
  //blacklist: ["loading"], //设置某个reducer数据不持久化，
  //注意单词的拼写！我就因为写错单词，找了半天,55555~
};
const reducers = combineReducers({
  userReducer,
  tabReducer,
  addressReducer,
  orderReducer
})

const myPersistReducer = persistReducer(persistConfig, reducers);

const store = createStore(myPersistReducer, applyMiddleware(thunk))

const persistor = persistStore(store);


export { store, persistor }


